import type { cartItemArray } from '@/types/cart'
import { http } from '@/utils/http'

//加入购物车
export const addCartApi = (data: { skuId: string; count: number }) => {
  return http({
    method: 'POST',
    url: '/member/cart',
    data,
  })
}
//获取购物车list
export const getCartApi = () => {
  return http<cartItemArray>({
    method: 'GET',
    url: '/member/cart',
  })
}
//删除
export const deleteApi = (data: { ids: string[] }) => {
  return http({
    method: 'DELETE',
    url: '/member/cart',
    data,
  })
}
//修改数量或选择全选
export const modifyOrselectApi = (skuId: string, data: { selected?: boolean; count?: number }) => {
  return http({
    method: 'PUT',
    url: `/member/cart/${skuId}`,
    data,
  })
}
//全选
//删除
export const allSelectedApi = (data: { selected: boolean }) => {
  return http({
    method: 'PUT',
    url: '/member/cart/selected',
    data,
  })
}
